<?php

/**
 * Created by PhpStorm.
 * Common: yf
 * Date: 2018/3/3
 * Time: 下午6:21
 */
namespace App\HttpController\Api;

use App\Msg\MsgCode;
use App\Utility\Validator;
use App\Logic\Friend\FriendLogic;
use EasySwoole\Core\Http\Message\Status;

class Friend extends AbstractBase {
	public function getFriendRequests() {
		$fs = (new FriendLogic ())->getFriendRequests ( $this->getUserInfo () );
		$this->jsonReturn ( Status::CODE_OK, $fs );
	}
	function dealFriendRequest() {
		$id = $this->request ()->getQueryParam ( "id" );
		$this->checkViewForm ( Validator::isEmpty ( $id ), MsgCode::FRIEND_KEY_NULL, "", "friend" );
		
		$status = $this->request ()->getQueryParam ( "status" );
		$this->checkViewForm ( Validator::isEmpty ( $status ), MsgCode::FRIEND_STATUS_NULL, "", "friend" );
		
		$fs = (new FriendLogic ())->dealFriendRequest ( $this->getUserInfo (), $id, $status );
		$this->jsonReturn ( Status::CODE_OK, $fs );
	}
	function getFriendList() {
		
		$fs = (new FriendLogic ())->getFriendList ( $this->getUserInfo () );
		$this->jsonReturn ( Status::CODE_OK, $fs );
	}
}